﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using CrystalDecisions.Web;
using CrystalDecisions.Windows;

namespace QLThuoc_report
{
    public partial class Frm_DanhMucThuoc : Form
    {
        public Frm_DanhMucThuoc()
        {
            InitializeComponent();
        }

        private void Frm_DanhMucThuoc_Load(object sender, EventArgs e)
        {
          SqlConnection  conn = new SqlConnection("Data Source =(local);Initial Catalog=QLThuoc;Integrated Security=true");
            SqlDataAdapter da = new SqlDataAdapter("SELECT     dbo.tbl_Thuoc.MaThuoc AS [Mã Thuốc], dbo.tbl_Thuoc.TenThuoc AS [Tên Thuốc], dbo.tbl_Thuoc.TenNCC AS [Nhà Cung Cấp],     dbo.tbl_LoaiThuoc.TenLoaiThuoc AS [Loại Thuốc], dbo.tbl_Thuoc.SoLuongTon AS [Số Lượng], dbo.tbl_Thuoc.DVT AS [Đơn Vị Tính], dbo.tbl_Thuoc.XuatXu AS [Xuất Xứ],     dbo.tbl_Thuoc.HanDung AS [Hạn Dùng], dbo.tbl_Thuoc.TacDung AS [Tác Dụng], dbo.tbl_Thuoc.GiaTien AS [Giá Tiền] FROM         dbo.tbl_LoaiThuoc INNER JOIN  dbo.tbl_Thuoc ON dbo.tbl_LoaiThuoc.MaLoaiThuoc = dbo.tbl_Thuoc.MaLoaiThuoc", conn);
            DataTable dt = new DataTable();
            da.Fill(dt);
            //lay duong dan du chuy?n sang máy tính nào c?ng ko b? l?i, ko có c?ng ðc nhýng sang máy tính khác s? ko ch?y ðc
            string path = Application.StartupPath;
            path = path.Substring(0, path.LastIndexOf("bin")) + "DMThuoc.rpt";
            DMThuoc report = new DMThuoc();
            report.SetDataSource(dt);
            crystalReportViewer1.ReportSource = report;
        }
    }
}
